<div th:fragment="control_condition_select_base">
	<script type="text/javascript">
		/** 下拉框元数据 */
		function metadata_select_base(params) {
			params = $.extend({}, {
				CONTROL_ID : "ID",
				TITLE : {
					TEXT : "TITLE"
				},
				DEFAULT : "false",
				RELATION : "",
				IS_SHOW_TOP : "0",
				SQL : ""
			}, params);
			return $.extend(new metadata_base(params), this);
		}

		/** 下拉框 元数据视图 面板视图 */
		function metadata_view_select_base(control) {
			this.CONTROL_ID = function() {
				var metadataName = "CONTROL_ID";
				var view = $($("#" + metadataName).html());
				var metadata = this.control.getMetadata();
				var _this = this;
				var mValue = metadata[metadataName];
				$(view).find("input").val(mValue).keyup(function() {
					metadata[metadataName] = $(this).val();
					_this.linkageMetadata(metadataName, $(this).val());
				}).popoverBind();
				$(this.settingPanel).append(view);
			}
			this.TITLE = function() {
				var metadataName = "TITLE";
				var view = $($("#SELECT_TITLE").html());
				var metadata = this.control.getMetadata();
				var _this = this;
				var mValue = metadata[metadataName];
				$(view).find("input").val(mValue.TEXT).on({
					keyup : function() {
						mValue.TEXT = $(this).val();
						_this.linkageMetadata(metadataName, mValue);
					}
				}).popoverBind();

				/**图标选择*/
				$(view).find("button").popover().click(function() {
					ImgSelectModel.show(function(id) {
						mValue["IMG_ID"] = id;
						_this.linkageMetadata(metadataName, mValue);
					})
				}).on('blur', function() {
					// 失去焦点时隐藏
					$(this).popover('hide');
				});

				$(this.settingPanel).append(view);
			}
			this.DEFAULT = function() {
				var metadataName = "DEFAULT";
				var view = $($("#" + metadataName).html());
				var metadata = this.control.getMetadata();
				var _this = this;
				var mValue = metadata[metadataName];
				$(view).find("select").val(mValue).change(function() {
					metadata[metadataName] = $(this).val();
				}).popoverBind();

				$(this.settingPanel).append(view);
			}
			this.RELATION = function() {
				var metadataName = "RELATION";
				var view = $($("#" + metadataName).html());
				var metadata = this.control.getMetadata();
				var _this = this;
				var mValue = metadata[metadataName];
				$(view).find("input").val(mValue).keyup(function() {
					metadata[metadataName] = $(this).val();
					_this.linkageMetadata(metadataName, $(this).val());
				}).popoverBind();
				$(this.settingPanel).append(view);
			}
			this.SQL = function() {
				var metadataName = "SQL";
				var view = $($("#" + metadataName).html());
				var metadata = this.control.getMetadata();
				var _this = this;
				var mValue = metadata[metadataName];
				$(view).find("textarea").val(mValue).keyup(function() {
					metadata.SQL = $(this).val();
				}).popoverBind();
				$(this.settingPanel).append(view);
			}
			this.IS_SHOW_TOP = function() {
				var metadataName = "IS_SHOW_TOP";
				var view = $($("#" + metadataName).html());
				var metadata = this.control.getMetadata();
				var _this = this;
				var mValue = metadata[metadataName];
				$(view).find("select").val(mValue).change(function() {
					metadata[metadataName] = $(this).val();
				}).popoverBind();
				$(this.settingPanel).append(view);
			}
			return $.extend(new metadata_view_base(control), this);
		}

		/** 下拉框 表单视图 */
		function metadata_form_view_select_base(control) {
			this.CONTROL_ID = function(value) {
				$(this.control).find(".list").attr("id", value);
			}
			this.TITLE = function(value) {
				$(this.control).find(".label-text").html(value.TEXT);
				var IMG_ID = value["IMG_ID"];
				if (!StringUtils.isEmpty(IMG_ID)) {
					var icon = $(this.control).find(".title-icon:eq(0)");
					var back = $(icon).css('backgroundImage');
					back = "/tjfx/image/recriveImage/" + IMG_ID;
					$(icon).removeAttr("style");
                    $(icon).attr("style",
							"background:url('" + back + "')  no-repeat");
                }
            }
            return $.extend(new metadata_form_view_base(control), this);
        }
	</script>



	<!-- 控制面板  下拉框 ID-->
	<script type="text/html" id="CONTROL_ID">
<div class="form-setting-group">
	<div class="controls">
		<label>控件ID<input data-content="该控件的唯一ID" data-trigger="manual"></label>
	</div>
</div>
</script>

	<!-- 控制面板  下拉框 标题-->
	<script type="text/html" id="SELECT_TITLE">
<div class="form-setting-group">
	<div class="controls">
		<label>控件标题<input data-content="该控件的标题名称" data-trigger="manual"></label>
		<button type="button" class="btn btn-default btn-sm" style="width: 98%;" >选择图标</button>
	</div>
</div>
</script>

	<!-- 控制面板  下拉框 是否显示在页面顶部-->
	<script type="text/html" id="IS_SHOW_TOP">
<div class="form-setting-group">
	<div class="controls">
		<label>是否显示在页面顶部</label>
		<select data-content="除行政区划下拉框外，不显示在页面顶部" data-trigger="manual">
			<option value="0">否</option>
			<option value="1">是</option>
		</select>
	</div>
</div>
</script>
	<!-- 控制面板  下拉框 默认项-->
	<script type="text/html" id="DEFAULT">
<div class="form-setting-group">
	<div class="controls">
		<label>是否启用不限：</label>
		<select data-content="启用不限条件" data-trigger="manual">
			<option value="false">否</option>
			<option value="true">是</option>
		</select>
	</div>
</div>
</script>
	<!-- 控制面板  下拉框 级联-->
	<script type="text/html" id="RELATION">
<div class="form-setting-group">
	<div class="controls">
		<label>级联关系主条件下拉框ID：</label>
		<input data-content="对应的级联下拉框ID" data-trigger="manual">
	</div>
</div>
</script>
	<!-- 控制面板  下拉框 SQL-->
	<script type="text/html" id="SQL">
<div class="form-setting-group">
	<div class="controls">
		<label>SQL</label><br>
		<textarea class="form-setting-sql" data-content="对应的查询结果SQL语句" data-trigger="manual" data-placement="top"></textarea>
	</div>
</div>
</script>
</div>
